﻿$.ajaxSetup({ cache: false });
function OpenURL(url, username) 
{

     var w = window.open(url, '_self');
    w.name = "UserName=" + username + " ";

}
function GetInterfaceURL() {

    return "http://dev.woga.aips.legensity.cn";
 
}

function GetUserInfoByJsonObject(id, username, token, type) 
{

    var jsonstring = "{ \"id\":\"" + id + "\", \"userName\":\"" + username + "\", \"type\":\"" + type + "\", \"token\":\"" + token + "\"}";
//    var jsonObject = $.parseJSON(jsonstring);
    return jsonstring;
 
}

function CheckIsLogin(username, spanid)
 {

    //    var UserID = GetUserIDByURL();
   
    if(username!="" && username!= undefined)
        //if (UserID != null && UserID != '0')
        {

         
            document.getElementById(spanid).innerHTML = "用户名：" + username;
       
      }
    else {
          window.open('Login.html', '_self');
    }
}

function Logout() 
{
     var w =window.open("Login.html", "_self")
    w.name = "UserName=0";
 
 
}
function GetUserIDByURL() 
{
    UserInfo = window.name.split("="); //对获得的参数字符串按照“=”进行分割
     UserID = UserInfo[1]; //得到参数值
    UserName = UserInfo[0];
    if (UserName == "UserName" && UserID != "") {

        return UserID;
    }
    else {

        return null;
    }
}

function GetQueryString(url) {
    urlinfo = window.location.href; //获取当前页面的url
    len = urlinfo.length; //获取url的长度
    offset = urlinfo.indexOf("?"); //设置参数字符串开始的位置
    newsidinfo = urlinfo.substr(offset, len)//取出参数字符串 这里会获得类似“id=1”这样的字符串
    newsids = newsidinfo.split("="); //对获得的参数字符串按照“=”进行分割
    newsid = newsids[1]; //得到参数值
    newsname = newsids[0]; //得到参数名字
    if (newsname == "?Phone") {
        return newsid;
    }
}

//获得URL的方法
function getQueryString(name) {
    
    var reg = new RegExp("(^|\\?|&)" + name + "=([^&]*)(\\s|&|$)", "i");
    if (reg.test(location.href)) return unescape(RegExp.$2.replace(/\+/g, " ")); return "";
};

function CheckUploadFileType(value) {
	var valid_extensions = /(.jpg|.jpeg|.gif|.png)$/i;
	if (!valid_extensions.test(value)) {
		alert("请选择 jpg/jpeg/gif/png 图片格式");
		return false;
	}
	return true;
}
 